package com.xxwy.protocal;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author wy
 * @date 2020/3/8 23:56
 */
public class XxwyEncoder extends MessageToByteEncoder<XxwyProtocol> {
  @Override
  protected void encode(ChannelHandlerContext channelHandlerContext, XxwyProtocol xxwyProtocol, ByteBuf byteBuf) throws Exception {
    System.out.println("xxwyencoder被调用");
    byteBuf.writeInt(xxwyProtocol.getLen());
    byteBuf.writeBytes(xxwyProtocol.getContent());
  }
}
